#Include "Protheus.ch"
#Include "XmlXFun.ch"

User Function TstNfeBra()

Local oWs        := WsNfeSBra():New()
Local cURL       := PadR(GetNewPar("MV_SPEDURL", "http://localhost:8080/sped"), 250)
Local cPath      := "C:\RelMicrosiga\"
Local cFile      := "file.xml"
Local oProtocolo := Nil

oWs:cUserToken              := "TOTVS"
oWs:cId_Ent                 := "000001"
oWs:cNFeConsultaProtocoloId := "31120661365557000110550010001557461005532148"
oWs:cChvNFe                 := "31120661365557000110550010001557461005532148"
oWs:_URL := AllTrim(cURL) + "/NFeSBRA.apw"

IF oWs:ConsultaProtocoloNFe()

	MsgInfo("Ok!")
	oProtocolo := oWs:oWSCONSULTAPROTOCOLONFERESULT

	SAVE oProtocolo XMLFILE "C:\RelMicrosiga\file.xml"

Else

	MsgInfo("Erro!")

EndIF

Return Nil